home *** CD-ROM | disk | FTP | other *** search
- /*
- File: InterruptSafeDebug.c
-
- Contains: Library for logging directly to the screen.
-
- Written by: Quinn "The Eskimo!"
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
-
- <1> 23/11/98 Quinn First checked in.
- */
-
- /////////////////////////////////////////////////////////////////////
-
- // Setup MoreIsBetter environment
-
- #include "MoreSetup.h"
-
- // Standard Mac OS interfaces
-
- #include <DriverSynchronization.h>
- #include <QuickDraw.h>
- #include <QDOffscreen.h>
- #include <OpenTransport.h>
- #include <CodeFragments.h>
- #include <Gestalt.h>
-
- // Our prototypes
-
- #include "InterruptSafeDebug.h"
-
- /////////////////////////////////////////////////////////////////////
-
- // This font data was generated by the GenerateFont program, the
- // source of which is included in the sample. Each row contains
- // 256 bytes, one for each character in the font. The rows represent
- // the scanline in the character.
-
- static UInt8 gFont[10][256] = {
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x10, 0x28, 0x28, 0x38, 0x3c, 0x30, 0x10, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x38, 0x08, 0x38, 0x38, 0x08, 0x7c, 0x38, 0x7c, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x78, 0x38, 0x78, 0x7c, 0x7c, 0x38, 0x44, 0x10, 0x04, 0x44, 0x40, 0x44, 0x44, 0x38, 0x78, 0x38, 0x78, 0x38, 0x7c, 0x44, 0x44, 0x44, 0x44, 0x44, 0x7c, 0x18, 0x20, 0x18, 0x10, 0x00, 0x10, 0x00, 0x40, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x40, 0x10, 0x10, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x34, 0x00, 0x38, 0x38, 0x38, 0x7c, 0x44, 0x38, 0x44, 0x10, 0x08, 0x28, 0x28, 0x58, 0x24, 0x00, 0x10, 0x10, 0x28, 0x28, 0x10, 0x10, 0x28, 0x28, 0x58, 0x10, 0x10, 0x28, 0x28, 0x58, 0x10, 0x10, 0x28, 0x28, 0x10, 0x24, 0x00, 0x48, 0x24, 0x00, 0x54, 0x24, 0x70, 0x70, 0x7a, 0x08, 0x28, 0x00, 0x3c, 0x38, 0x00, 0x00, 0x08, 0x10, 0x44, 0x00, 0x10, 0x7c, 0x7c, 0x00, 0x10, 0x1c, 0x18, 0x38, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x14, 0x08, 0x18, 0x00, 0x00, 0x28, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x10, 0x28, 0x7c, 0x54, 0x54, 0x48, 0x10, 0x10, 0x08, 0x54, 0x10, 0x00, 0x00, 0x00, 0x04, 0x44, 0x18, 0x44, 0x44, 0x18, 0x40, 0x40, 0x04, 0x44, 0x44, 0x00, 0x00, 0x08, 0x00, 0x20, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x40, 0x44, 0x44, 0x10, 0x04, 0x48, 0x40, 0x6c, 0x64, 0x44, 0x44, 0x44, 0x44, 0x44, 0x10, 0x44, 0x44, 0x44, 0x28, 0x44, 0x04, 0x10, 0x20, 0x08, 0x28, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x58, 0x00, 0x44, 0x44, 0x44, 0x40, 0x64, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x24, 0x10, 0x40, 0x50, 0x38, 0x54, 0x44, 0x08, 0x08, 0x2e, 0x10, 0x00, 0x08, 0x50, 0x44, 0x00, 0x10, 0x10, 0x08, 0x28, 0x00, 0x08, 0x24, 0x28, 0x00, 0x10, 0x24, 0x24, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x10, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x50, 0x00, 0x00, 0x00, 0x28, 0x14, 0x10, 0x08, 0x10, 0x10, 0x00, 0x7e, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x10, 0x00, 0x28, 0x50, 0x58, 0x50, 0x00, 0x20, 0x04, 0x38, 0x10, 0x00, 0x00, 0x00, 0x08, 0x44, 0x08, 0x04, 0x04, 0x28, 0x78, 0x78, 0x04, 0x44, 0x44, 0x10, 0x10, 0x10, 0x7c, 0x10, 0x04, 0x74, 0x44, 0x44, 0x40, 0x44, 0x40, 0x40, 0x40, 0x44, 0x10, 0x04, 0x50, 0x40, 0x54, 0x54, 0x44, 0x44, 0x44, 0x44, 0x40, 0x10, 0x44, 0x44, 0x44, 0x10, 0x44, 0x08, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x3c, 0x78, 0x38, 0x3c, 0x38, 0x38, 0x3c, 0x78, 0x10, 0x10, 0x48, 0x10, 0x78, 0x58, 0x38, 0x78, 0x3c, 0x58, 0x3c, 0x38, 0x44, 0x44, 0x54, 0x44, 0x44, 0x7c, 0x08, 0x10, 0x10, 0x00, 0x00, 0x44, 0x44, 0x40, 0x40, 0x54, 0x44, 0x44, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x38, 0x38, 0x38, 0x38, 0x38, 0x10, 0x10, 0x10, 0x10, 0x58, 0x38, 0x38, 0x38, 0x38, 0x38, 0x44, 0x44, 0x44, 0x44, 0x10, 0x18, 0x38, 0x70, 0x48, 0x7c, 0x54, 0x48, 0x64, 0x34, 0x2e, 0x00, 0x00, 0x7c, 0x50, 0x4c, 0x6c, 0x10, 0x20, 0x04, 0x7c, 0x48, 0x0c, 0x10, 0x28, 0x7c, 0x10, 0x24, 0x24, 0x44, 0x38, 0x38, 0x10, 0x08, 0x00, 0x08, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x50, 0x28, 0x00, 0x00, 0x28, 0x28, 0x18, 0x10, 0x00, 0x28, 0x44, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x10, 0x00, 0x7c, 0x38, 0x28, 0x20, 0x00, 0x20, 0x04, 0x54, 0x7c, 0x00, 0x7c, 0x00, 0x08, 0x44, 0x08, 0x08, 0x18, 0x48, 0x04, 0x44, 0x08, 0x38, 0x44, 0x00, 0x00, 0x20, 0x00, 0x08, 0x08, 0x54, 0x7c, 0x78, 0x40, 0x44, 0x78, 0x78, 0x4c, 0x7c, 0x10, 0x04, 0x60, 0x40, 0x44, 0x4c, 0x44, 0x78, 0x44, 0x78, 0x38, 0x10, 0x44, 0x44, 0x44, 0x10, 0x28, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x10, 0x44, 0x44, 0x10, 0x10, 0x50, 0x10, 0x54, 0x64, 0x44, 0x44, 0x44, 0x64, 0x40, 0x10, 0x44, 0x44, 0x54, 0x28, 0x44, 0x08, 0x10, 0x10, 0x08, 0x00, 0x00, 0x7c, 0x7c, 0x40, 0x78, 0x4c, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x10, 0x10, 0x10, 0x10, 0x64, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x10, 0x00, 0x54, 0x40, 0x24, 0x7c, 0x3c, 0x48, 0x54, 0x44, 0x00, 0x00, 0x00, 0x10, 0x78, 0x54, 0x54, 0x7c, 0x10, 0x08, 0x10, 0x48, 0x14, 0x08, 0x28, 0x28, 0x10, 0x1c, 0x18, 0x44, 0x54, 0x4c, 0x20, 0x08, 0x7c, 0x10, 0x10, 0x44, 0x28, 0x24, 0x48, 0x00, 0x00, 0x7c, 0x7c, 0x44, 0x58, 0x54, 0x38, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x44, 0x44, 0x7e, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x10, 0x00, 0x28, 0x14, 0x34, 0x54, 0x00, 0x20, 0x04, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x44, 0x08, 0x10, 0x04, 0x7c, 0x04, 0x44, 0x10, 0x44, 0x3c, 0x00, 0x00, 0x10, 0x7c, 0x10, 0x10, 0x78, 0x44, 0x44, 0x40, 0x44, 0x40, 0x40, 0x44, 0x44, 0x10, 0x44, 0x50, 0x40, 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x04, 0x10, 0x44, 0x44, 0x54, 0x10, 0x10, 0x20, 0x10, 0x08, 0x08, 0x00, 0x00, 0x00, 0x44, 0x44, 0x40, 0x44, 0x7c, 0x10, 0x44, 0x44, 0x10, 0x10, 0x70, 0x10, 0x54, 0x44, 0x44, 0x44, 0x44, 0x40, 0x38, 0x10, 0x44, 0x44, 0x54, 0x10, 0x44, 0x10, 0x08, 0x10, 0x10, 0x00, 0x00, 0x44, 0x44, 0x40, 0x40, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x7c, 0x7c, 0x7c, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x10, 0x00, 0x50, 0x40, 0x14, 0x7c, 0x14, 0x44, 0x64, 0x34, 0x00, 0x00, 0x00, 0x7c, 0x50, 0x64, 0x6c, 0x10, 0x08, 0x10, 0x7c, 0x48, 0x24, 0x10, 0x28, 0x28, 0x10, 0x00, 0x00, 0x44, 0x5c, 0x54, 0x40, 0x08, 0x04, 0x50, 0x10, 0x38, 0x28, 0x48, 0x24, 0x00, 0x00, 0x44, 0x44, 0x44, 0x50, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x44, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x54, 0x54, 0x48, 0x00, 0x10, 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x44, 0x08, 0x20, 0x44, 0x08, 0x44, 0x44, 0x10, 0x44, 0x04, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 0x40, 0x44, 0x44, 0x44, 0x44, 0x40, 0x40, 0x44, 0x44, 0x10, 0x44, 0x48, 0x40, 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x10, 0x44, 0x28, 0x6c, 0x28, 0x10, 0x40, 0x10, 0x08, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x44, 0x40, 0x44, 0x40, 0x10, 0x44, 0x44, 0x10, 0x10, 0x48, 0x10, 0x54, 0x44, 0x44, 0x44, 0x44, 0x40, 0x04, 0x10, 0x4c, 0x28, 0x54, 0x28, 0x44, 0x20, 0x08, 0x10, 0x10, 0x00, 0x00, 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x10, 0x10, 0x10, 0x10, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x00, 0x54, 0x44, 0x48, 0x38, 0x14, 0x44, 0x58, 0x08, 0x00, 0x00, 0x00, 0x20, 0x50, 0x44, 0x00, 0x10, 0x00, 0x00, 0x10, 0x48, 0x24, 0x24, 0x28, 0x28, 0x10, 0x3c, 0x3c, 0x28, 0x50, 0x64, 0x44, 0x08, 0x04, 0x20, 0x10, 0x40, 0x44, 0x48, 0x24, 0x00, 0x00, 0x44, 0x44, 0x44, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x44, 0x7e, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x10, 0x00, 0x00, 0x38, 0x48, 0x34, 0x00, 0x08, 0x10, 0x00, 0x00, 0x10, 0x00, 0x10, 0x20, 0x38, 0x08, 0x7c, 0x38, 0x08, 0x38, 0x38, 0x10, 0x38, 0x38, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x38, 0x44, 0x78, 0x38, 0x78, 0x7c, 0x40, 0x38, 0x44, 0x10, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x38, 0x40, 0x38, 0x44, 0x38, 0x10, 0x38, 0x10, 0x44, 0x44, 0x10, 0x7c, 0x18, 0x04, 0x18, 0x00, 0x7e, 0x00, 0x34, 0x78, 0x3c, 0x3c, 0x3c, 0x10, 0x3c, 0x44, 0x10, 0x10, 0x44, 0x10, 0x54, 0x44, 0x38, 0x78, 0x3c, 0x40, 0x78, 0x0c, 0x34, 0x10, 0x28, 0x44, 0x3c, 0x7c, 0x08, 0x10, 0x10, 0x00, 0x00, 0x44, 0x44, 0x38, 0x7c, 0x44, 0x38, 0x38, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x10, 0x10, 0x10, 0x10, 0x44, 0x38, 0x38, 0x38, 0x38, 0x38, 0x34, 0x34, 0x34, 0x34, 0x00, 0x00, 0x38, 0x78, 0x44, 0x00, 0x14, 0x58, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x38, 0x00, 0x7c, 0x38, 0x1c, 0x10, 0x74, 0x18, 0x7c, 0x28, 0x28, 0x10, 0x00, 0x00, 0x6c, 0x3c, 0x38, 0x38, 0x08, 0x00, 0x20, 0x10, 0x00, 0x7c, 0x24, 0x48, 0x54, 0x00, 0x44, 0x44, 0x38, 0x3c, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x38, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
- };
-
- static UInt8 *gScreenBase;
- // The base of the main screen buffer.
-
- static ByteCount gRowBytes;
- // The rowbytes for the main screen buffer.
-
- static UInt16 gBytesPerChar;
- // The number of bytes in a scanline that each character consumes.
- // This is equivalent to the bit depth. For example, in B&W mode,
- // this is 1 (8 pixels across, at 1 bit per pixel), and in 8 bit mode
- // this is 8 (8 pixels across, at 8 bits per pixel).
-
- static ByteCount gCurrentCharIndex;
- // The index of the next slot where a character will be
- // plotted on the screen. This is always manipulated by
- // atomic routines, which guarantees interrupt safety.
- // It wraps around freely, so must be MODed by kISDebugMaxCharIndex
- // to get the actual placement.
-
- /////////////////////////////////////////////////////////////////////
-
- #if GENERATINGPOWERPC
-
- extern UInt32 AddAtomicForNonDSL(UInt32 amount, UInt32 *value);
- // This routine is used only if DriverServicesLib is not
- // available.
-
- #endif
-
- static UInt32 AddAtomicCompat(UInt32 amount, UInt32 *value)
- // This routine is a standard "atomic add" function.
- // It has two purposes:
- // 1. It adapts AddAtomic to work with unsigned numbers.
- // 2. It binds to correct AddAtomic (DSL on modern machines,
- // custom on pre-PCI machines).
- // 3. It uses the OTAtomicAdd on 68K, munging the result
- // to match the behaviour of AddAtomic.
- {
- #if GENERATING68K
- // OTAtomicAdd32 is declared inline in "OpenTransport.h",
- // so you can use it regardless of whether OT is installed,
- // and without calling InitOpenTransport.
- return OTAtomicAdd32((SInt32) amount, (SInt32 *) value) - amount;
- #else
- if ( false && AddAtomic == (void *) kUnresolvedCFragSymbolAddress) {
- return AddAtomicForNonDSL(amount, value);
- } else {
- return AddAtomic((SInt32) amount, (SInt32 *) value);
- }
- #endif
- }
-
- /////////////////////////////////////////////////////////////////////
-
- static void PlotChar(UInt8 thisChar, ByteCount thisCharIndex)
- {
- UInt8 *charStart;
- ByteCount scanLine;
- ByteCount row;
- ByteCount col;
- UInt8 ch;
- ByteCount pixel;
-
- MoreAssertQ(thisCharIndex < kISDebugMaxCharIndex);
-
- row = thisCharIndex / kISDebugNumberOfColumns;
- col = thisCharIndex % kISDebugNumberOfColumns;
- charStart = gScreenBase + row * gRowBytes * 10 + col * gBytesPerChar + kISDebugXPixelOffset + kISDebugYPixelOffset * gRowBytes;
- switch (gBytesPerChar) {
- case 1:
- for (scanLine = 0; scanLine < 10; scanLine++) {
- *charStart = gFont[scanLine][thisChar];
- charStart += gRowBytes;
- }
- break;
- case 4:
- for (scanLine = 0; scanLine < 10; scanLine++) {
- ch = gFont[scanLine][thisChar];
- for (pixel = 0; pixel < 8; pixel++) {
- if (ch & 0x080) {
- charStart[pixel / 2] |= (pixel % 2) ? 0x0F : 0xF0;
- } else {
- charStart[pixel / 2] &= (pixel % 2) ? 0xF0 : 0x0F;
- }
- ch = ch << 1;
- }
- charStart += gRowBytes;
- }
- break;
- case 8:
- for (scanLine = 0; scanLine < 10; scanLine++) {
- ch = gFont[scanLine][thisChar];
- for (pixel = 0; pixel < 8; pixel++) {
- if (ch & 0x080) {
- charStart[pixel] = 0xFF;
- } else {
- charStart[pixel] = 0x00;
- }
- ch = ch << 1;
- }
- charStart += gRowBytes;
- }
- break;
- case 16:
- for (scanLine = 0; scanLine < 10; scanLine++) {
- ch = gFont[scanLine][thisChar];
- for (pixel = 0; pixel < 8; pixel++) {
- if (ch & 0x080) {
- ((UInt16 *) charStart)[pixel] = 0x0000;
- } else {
- ((UInt16 *) charStart)[pixel] = 0x7FFF;
- }
- ch = ch << 1;
- }
- charStart += gRowBytes;
- }
- break;
- case 32:
- for (scanLine = 0; scanLine < 10; scanLine++) {
- ch = gFont[scanLine][thisChar];
- for (pixel = 0; pixel < 8; pixel++) {
- if (ch & 0x080) {
- ((UInt32 *) charStart)[pixel] = 0x00000000;
- } else {
- ((UInt32 *) charStart)[pixel] = 0x00FFFFFF;
- }
- ch = ch << 1;
- }
- charStart += gRowBytes;
- }
- break;
- default:
- // do nothing
- break;
- }
- }
-
- extern void ISDebugChar(UInt8 ch)
- // See comment in interface part.
- {
- ISDebugText(&ch, sizeof(ch));
- }
-
- extern void ISDebugText(const UInt8 *text, ByteCount len)
- // See comment in interface part.
- {
- UInt32 lastCharIndex;
-
- // For interrupt-safeness, it's critical that this add be
- // atomic.
-
- lastCharIndex = AddAtomicCompat(len + 2, &gCurrentCharIndex) + len + 2;
-
- // Plotting this bullet is not 100% interrupt safe (we're assuming
- // that an interrupt hasn't come in between the AddAtomic and the plot
- // and written text which the bullet is going to overwrite) but it's
- // sufficiently useful in helping you find the last logged text
- // that I'm prepared to accept the uncertainty.
-
- PlotChar('•', lastCharIndex % kISDebugMaxCharIndex);
- lastCharIndex -= 1;
-
- PlotChar('»', lastCharIndex % kISDebugMaxCharIndex);
- while (len != 0) {
- len -= 1;
- lastCharIndex -= 1;
- PlotChar(text[len], lastCharIndex % kISDebugMaxCharIndex);
- }
- lastCharIndex -= 1;
- PlotChar('«', lastCharIndex % kISDebugMaxCharIndex);
- }
-
- extern void ISDebugStr (ConstStr255Param str)
- // See comment in interface part.
- {
- ISDebugText(&str[1], str[0]);
- }
-
- static ByteCount MyStrLen(const char * str)
- // Include my own strlen function because I want to avoid
- // linking with standard C libraries.
- {
- ByteCount len = -1;
- do {
- len++;
- } while (*str++);
- return(len);
- }
-
- extern void ISdebugstr (const char *str)
- // See comment in interface part.
- {
- ISDebugText( (UInt8 *) str, MyStrLen(str));
- }
-
- /////////////////////////////////////////////////////////////////////
-
- enum {
- kTestForColourQuickDraw = true
- // You might want set this if, for example, your
- // compiling in an environment where a) you know
- // you have Colour QuickDraw and b) touching "qd"
- // is causing link errors.
- };
-
- static Boolean HasColourQuickDraw(void)
- // A standard test routine. Note that you should
- // always test using the gestaltQuickdrawVersion, not
- // gestaltQuickdrawFeatures, because the latter
- // lies on a PB100 running System 7.0 or higher.
- {
- UInt32 response;
-
- return Gestalt(gestaltQuickdrawVersion, (SInt32 *) &response) == noErr &&
- response >= gestaltOriginalQD;
- }
-
- extern OSStatus InitInterruptSafeDebug(void)
- {
- OSStatus err;
- Rect bounds;
-
- err = noErr;
-
- if ( kTestForColourQuickDraw && HasColourQuickDraw() ) {
- PixMapHandle mainDevPM;
-
- mainDevPM = (**GetMainDevice()).gdPMap;
-
- // PixelSize is in bits, multiply by 8 for the number of pixels
- // each character is across, divided by 8 to get bytes.
-
- gBytesPerChar = (**mainDevPM).pixelSize * 8 / 8;
- gScreenBase = (UInt8 *) GetPixBaseAddr(mainDevPM);
- gRowBytes = ((**mainDevPM).rowBytes) & 0x3FFF;
- bounds = (**mainDevPM).bounds;
-
- // If we're running on a machine with 24 bit addressing
- // but the pixmap requires 32 bit addressing to access,
- // spit out an error. I'm too lazy to handle this weird
- // case in my blitters.
-
- if ( GetMMUMode() == false32b && PixMap32Bit(mainDevPM) ) {
- err = -4;
- }
- } else {
- gBytesPerChar = 1;
- gScreenBase = (UInt8 *) qd.screenBits.baseAddr;
- gRowBytes = qd.screenBits.rowBytes;
- bounds = qd.screenBits.bounds;
- }
-
- if ( (bounds.right - bounds.left) < kISDebugNumberOfColumns * 8 + kISDebugXPixelOffset ) {
- err = -1;
- }
- if ( (bounds.bottom - bounds.top) < kISDebugNumberOfRows * 10 + kISDebugYPixelOffset ) {
- err = -2;
- }
- switch (gBytesPerChar) {
- case 1:
- case 4:
- case 8:
- case 16:
- case 32:
- break;
- default:
- // Everything else is left as an exercise for the reader.
- err = -3;
- break;
- }
-
- return err;
- }
-